<?php

namespace app\index\controller;

use think\Controller;
use think\Db;
use think\Cookie;
use think\Session;

class Common extends Controller
{
    public function _initialize()
    {
        //foot信息
        $array = array();
        $foot = db('config')->where('group', '1')->select();
        foreach ($foot as &$vas) {
            $array[$vas['name']] = $vas['value'];
        }
        $this->assign('footcompany', $array);

        //导航栏
        $where_nav['status'] = ['eq', 1]; //推荐1
        $navigation = db('nav')->where($where_nav)->select();
        $this->assign('navigation', $navigation);
        //每页显示条数
        $pagesarray = array();
        $pages = db('config')->where('group', '2')->select();
        foreach ($pages as &$val) {
            $pagesarray[$val['name']] = $val['value'];
        }
        $this->pages = $pagesarray['web_pages'];
        //是否注册
        $register = db('config')->where('group', '3')->find();
        if (!$register) {
            $register['value'] = '1'; //默认开启
        }
        $this->assign('register', $register);

        $config = cache('db_config_data');
        if (!$config) {
            $config = api('Config/lists');
            cache('db_config_data', $config);
        }
        config($config);
        $local_host = get_localdomain_host();
        $this->assign('local_host', $local_host);
    }

    public function index()
    {
        return $this->fetch();
    }

    //分类
    public function articlecate()
    {
        $articlecate = db('article_cate')->select();
        return $articlecate;
    }

    //标签
    public function label()
    {
        $label = db('label')->select();
        return $label;
    }

}
